Skip to content

Conversation

@sfleen
Copy link
Contributor

@sfleen sfleen commented Oct 6, 2025

Currently, we add a label that identifies the parent resource that a proxy is attached to, usually a deployment, statefulset, daemonset, etc. These are populated via linkerd.io/proxy-<resource> annotations, with a different label for each parent resource.

There are a few deficiencies with the current implementation. Currently, the implementation is specialized to only built-in k8s resources, so things like argocd rollouts will not appear. Additionally it does not recurse beyond two levels, so any more levels of parenting will not be captured.

This adds a pair of new labels, linkerd.io/proxy-root-parent and linkerd.io/proxy-root-parent-kind, that identify the name and kind of the root parent of a proxy workload. It also correctly recurses to the true root resource, at least as far as cluster role permissions for the proxy injector permit.

Note that the proxy already consumes all of the pod labels via the downward API, so there's no changes required to the proxy injector templates.

@sfleen sfleen force-pushed the sfleen/trace-parent branch from e57df5a to 1d643ee Compare October 6, 2025 18:08
@sfleen sfleen changed the title feat: Add label for root parent object feat: Add labels for root parent object Oct 6, 2025
@sfleen sfleen marked this pull request as ready for review October 6, 2025 18:29
@sfleen sfleen requested a review from a team as a code owner October 6, 2025 18:29
@sfleen sfleen requested a review from alpeb October 6, 2025 18:30
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

I guess the path forward is to remove the old logic along with its labels. If so, can you flag that in the the the labels.go's label entry godoc? Should also be mentioned in the release notes.

sfleen added 3 commits October 6, 2025 16:25
The GroupVersionResource requires the resource to be both lowercase and plural.

Signed-off-by: Scott Fleener <[email protected]>
@olix0r
Copy link
Member

olix0r commented Oct 7, 2025

I don't think 'kind' is sufficient. I think we must also include 'group'

sfleen and others added 2 commits October 8, 2025 12:17
@sfleen
Copy link
Contributor Author

sfleen commented Oct 8, 2025

I added in the group as an annotation, as well as some more webhook tests to make sure we have more coverage here.

@sfleen sfleen enabled auto-merge (squash) October 8, 2025 16:43
@sfleen sfleen merged commit f2989ea into main Oct 8, 2025
67 of 69 checks passed
@sfleen sfleen deleted the sfleen/trace-parent branch October 8, 2025 16:51
sfleen added a commit that referenced this pull request Oct 8, 2025
This replaces the old pod owner mechanism with the new one introduced by #14578. This retains the previous annotations for now, we can remove them later in a follow-up.

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Oct 8, 2025
This replaces the old pod owner mechanism with the new one introduced by #14578. This retains the previous annotations for now, we can remove them later in a follow-up.

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Oct 8, 2025
This replaces the old pod owner mechanism with the new one introduced by #14578. This retains the previous annotations for now, we can remove them later in a follow-up.

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Oct 8, 2025
This replaces the old pod owner mechanism with the new one introduced by #14578. This retains the previous annotations for now, we can remove them later in a follow-up.

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Oct 9, 2025
* chore(inject): Replace root owner mechanism

This replaces the old pod owner mechanism with the new one introduced by #14578. This retains the previous annotations for now, we can remove them later in a follow-up.

Signed-off-by: Scott Fleener <[email protected]>

* chore(inject): Remove version from root owner labels

Signed-off-by: Scott Fleener <[email protected]>

* chore(tests): Update goldens

Signed-off-by: Scott Fleener <[email protected]>

---------

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Oct 13, 2025
sfleen added a commit that referenced this pull request Oct 13, 2025
sfleen added a commit that referenced this pull request Oct 13, 2025
* Revert "chore(inject): Replace root owner mechanism (#14593)"

This reverts commit 9f5201e.

* Revert "feat: Add labels for root parent object (#14578)"

This reverts commit f2989ea

Signed-off-by: Scott Fleener <[email protected]>

---------

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Nov 4, 2025
This is a roll-forward of #14578, albiet with a slightly different implementation. The original PR would fall back to direct metadata API calls when getting resources from the informer cache. This instead resyncs the informer when a resource cannot be found and tries again, skipping the direct metadata API entirely.

Original PR description:

Currently, we add a label that identifies the parent resource that a proxy is attached to, usually a deployment, statefulset, daemonset, etc. These are populated via `linkerd.io/proxy-<resource>`` annotations, with a different label for each parent resource.

There are a few deficiencies with the current implementation. Currently, the implementation is specialized to only built-in k8s resources, so things like argocd rollouts will not appear. Additionally it does not recurse beyond two levels, so any more levels of parenting will not be captured.

This adds a set of new labels, `linkerd.io/proxy-root-parent` and `linkerd.io/proxy-root-parent-kind`, and `linkerd.io/proxy-root-parent-group`, that identify the name and kind of the root parent of a proxy workload. It also correctly recurses to the true root resource, at least as far as cluster role permissions for the proxy injector permit.

Note that the proxy already consumes all of the pod labels via the downward API, so there's no changes required to the proxy injector templates.

Signed-off-by: Scott Fleener <[email protected]>
sfleen added a commit that referenced this pull request Nov 4, 2025
This is a roll-forward of #14578, albiet with a slightly different implementation. The original PR would fall back to direct metadata API calls when getting resources from the informer cache. This instead resyncs the informer when a resource cannot be found and tries again, skipping the direct metadata API entirely.

Original PR description:

Currently, we add a label that identifies the parent resource that a proxy is attached to, usually a deployment, statefulset, daemonset, etc. These are populated via `linkerd.io/proxy-<resource>`` annotations, with a different label for each parent resource.

There are a few deficiencies with the current implementation. Currently, the implementation is specialized to only built-in k8s resources, so things like argocd rollouts will not appear. Additionally it does not recurse beyond two levels, so any more levels of parenting will not be captured.

This adds a set of new labels, `linkerd.io/proxy-root-parent` and `linkerd.io/proxy-root-parent-kind`, and `linkerd.io/proxy-root-parent-group`, that identify the name and kind of the root parent of a proxy workload. It also correctly recurses to the true root resource, at least as far as cluster role permissions for the proxy injector permit.

Note that the proxy already consumes all of the pod labels via the downward API, so there's no changes required to the proxy injector templates.

Signed-off-by: Scott Fleener <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants